/** @jsxImportSource @emotion/react */
import * as React from "react";
import {CCell, Cell, Table, TableBody, TableRow, Text,} from "customize-easy-ui-component";
import Img_Seal from "../../../images/seal.png";
import {CCellUnit, RepLink} from "../../common/base";
import {config设备概况} from "./orcBase";
import {useThreeColumnView} from "../../hook/useThreeColumnSubr";

//页眉不适合放入动态数据，对原版本的修改： 报告编号： 放入主体部分。兼容性；
export const 测试综合报告= ({ orc, rep,theme } : { orc: any, rep: any,theme:any}
) => {
  const [renderUpper,renderMiddle]=useThreeColumnView({orc, config:config设备概况,slash:true,split:[6]});
        // const renderUpper=usePrefixDataTable({config: config设备概况, orc, rep, slash:true});
  return <>
    <div css={{"@media print": {paddingBottom: '3.5rem', pageBreakInside: 'avoid'}}}>
      <Text id={'Conclusion'} variant="h2" css={{textAlign: 'center', marginTop: '1rem',
      }}>一、锅炉能效测试综合报告</Text>
      <div css={{display: 'flex', justifyContent: 'space-between'}}>
        <Text></Text>
        <Text>报告编号：{rep.isp.no}</Text>
      </div>
    </div>
    <Table fixed={ ["12.1%", "%","8.3%", "23%", "10.1%", "22%"] }
           css={{borderCollapse: 'collapse', "@media print": {marginTop: '-3.5rem'}}} tight miniw={800}>
      <TableBody>
        <RepLink rep={rep} tag={'Survey'}>
          {renderUpper}
        </RepLink>
      </TableBody>
    </Table>
    <Table fixed={ ["12.1%", "%","8.3%", "8.3%", "6%", "17%"] }
           css={{borderCollapse: 'collapse', }} tight miniw={800}>
      <TableBody>
        <RepLink rep={rep} tag={'Survey'}>
          {renderMiddle}
        </RepLink>
        <RepLink rep={rep} tag={'Conclusion'}>
          <TableRow >
            <CCell>测试依据</CCell>
            <Cell colSpan={5}>
              {orc.依节能环 && <>TSG 91-2021《锅炉节能环保技术规程》<br/></>}
              {orc.依热工性 && <>NB/T 47066-2018《冷凝锅炉热工性能试验方法》<br/></>}
              {orc.依规程 && <>GB/T 10180-2017《工业锅炉热工性能试验规程》<br/></>}
              {orc.依合同 && <>双方签订的合同中有关技术要求。<br/></>}
              {!orc.依节能环 && !orc.依热工性 && !orc.依规程 && !orc.依合同 && ' ／'}
            </Cell>
          </TableRow>
          <TableRow>
            <CCell>测试性质</CCell>
            <CCell colSpan={1}>{orc.试性质 ?? '／'}</CCell>
            <CCell>测试方法</CCell>
            <CCell colSpan={3}>{orc.试方法 ?? '／'}</CCell>
          </TableRow>
        </RepLink>
      </TableBody>
    </Table>
    <Table  fixed={ ["5.3%","11%","39%","19%","%"] } css={ {borderCollapse: 'collapse' } } tight  miniw={800}>
      <TableBody>
        <RepLink rep={rep} tag={'Conclusion'}>
          <TableRow  css={{"@media print": {pageBreakInside: 'avoid',}}}>
            <CCell rowSpan={2}>测试结果</CCell>
            <CCell>锅炉负荷</CCell>
            <CCellUnit unit={orc?.是功率?'MW' :'t/h'}>{orc?.炉负荷 ?? '／'}</CCellUnit>
            <CCell>锅炉热效率</CCell>
            <CCellUnit unit={'%'}>{orc?.结炉热效 ??'／'}</CCellUnit>
          </TableRow>
          <TableRow>
            <CCell>排烟温度</CCell>
            <CCellUnit unit={'℃'}>{orc?.结排烟温 ?? '／'}</CCellUnit>
            <CCell>排烟处过量空气系数</CCell>
            <CCell>{orc.过量空气 || '／'}</CCell>
          </TableRow>
          <TableRow>
            <CCell  scope="row">测试结论</CCell>
            <Cell colSpan={4}><div css={{minHeight: '6rem', whiteSpace: 'pre-wrap'}}>
              {orc.结论说明 || '／'}
            </div></Cell>
          </TableRow>
        </RepLink>
      </TableBody>
    </Table>
    {检验结论Thme({theme, orc, rep})}
    <Text css={{fontSize:'0.7rem'}}>
    </Text>
  </>;
};

//测试人员： 报告这里没有录入的。采用业务生成的？
export const 检验结论Thme= ({theme, orc, rep,nextjycl='定期检验',rysx1='编制'} :{theme: any, orc:any, rep:any,nextjycl?:string,rysx1?:string}
) => {
  //fontSize: theme.fontSizes[0],
  //【字体大小一致性】 确保字体一致 0.875rem 是来自Cell默认 @ 但，非表格内的其它文本 默认 font-size: 1rem;
  return <>
    <Table fixed={ ["65%","%"] }  css={ {borderCollapse: 'collapse' } }  tight  miniw={800}>
      <TableBody>
        <RepLink rep={rep} tag={'Conclusion'}>
          <TableRow>
            <Cell colSpan={2}><div css={{margin: '0 0.5rem', whiteSpace: 'pre-wrap'}}>
              测试人员：&nbsp;{orc.检验人IDs ??'／'}
            </div></Cell>
          </TableRow>
          <TableRow>
            <Cell><div css={{margin: '0 0.5rem'}}>
              测试负责人：&nbsp;{orc.检验人IDs ??'／'}
            </div></Cell>
            <CCell rowSpan={4}>
              <div css={{
                height: '8rem',
                '::before': {
                  filter: 'opacity(30%)',
                  width: '100%',
                  height: '100%',
                  backgroundImage: `url(${Img_Seal})`,
                  content: '" "',
                  position: 'absolute',
                  top: 0,
                  left: 0,
                  backgroundRepeat: 'no-repeat',
                  backgroundPosition: 'center',
                }
              }}>
                <Table  fixed={ ["60%","%"]  } css={ {borderCollapse: 'collapse',height:'fill-available'} }>
                  <TableBody>
                    <TableRow>
                      <CCell css={{border:'none'}}></CCell>
                    </TableRow>
                    <TableRow>
                      <CCell css={{border:'none'}} colSpan={2}>（测试机构测试专用章）</CCell>
                    </TableRow>
                    <TableRow>
                      <CCell css={{border:'none'}}></CCell>
                      <Cell css={{border:'none'}}>2024/07/31</Cell>
                    </TableRow>
                  </TableBody>
                </Table>
              </div>
            </CCell>
          </TableRow>
          <TableRow>
            <Cell><div css={{margin: '0 0.5rem',display: 'flex',justifyContent: 'space-between'}}>
              <Text css={{fontSize: '0.875rem'}}>报告编制：&nbsp;{orc.检验人IDs ??'／'}</Text>
              <Text css={{fontSize: '0.875rem'}}>2027-07-31</Text>
            </div></Cell>
          </TableRow>
        </RepLink>
        <TableRow>
          <Cell><div css={{margin: '0 0.5rem', display: 'flex', justifyContent: 'space-between'}}>
              <Text css={{fontSize: '0.875rem'}}>报告审核：&nbsp;{orc.检验人IDs ?? '／'}</Text>
              <Text css={{fontSize: '0.875rem'}}></Text>
            </div></Cell>
        </TableRow>
        <TableRow>
          <Cell><div css={{margin: '0 0.5rem', display: 'flex', justifyContent: 'space-between'}}>
            <Text css={{fontSize: '0.875rem'}}>报告批准：&nbsp;{orc.检验人IDs ?? '／'}</Text>
            <Text css={{fontSize: '0.875rem'}}></Text>
          </div></Cell>
        </TableRow>
      </TableBody>
    </Table>
  </>;
};
